// pages/record/component/record-item.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    itemData: Object,
    
  },

  observers: {
    'itemData'(itemData) {
      this.updateData()
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    // address: String,
    upDataString: '',
    downDataString: '',
  },

  lifetimes: {
    attached() {
      this.updateData()
    },

    ready: function() {
    },

    moved: function() {
    },
    
    detached: function() {
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {
    updateData: function() {
      const baZi = this.properties.itemData.baZi
      if (baZi.length == 8) {
        const key0 = baZi[0]
        const key1 = baZi[1]
        const key2 = baZi[2]
        const key3 = baZi[3]
        const key4 = baZi[4]
        const key5 = baZi[5]
        const key6 = baZi[6]
        const key7 = baZi[7]
        this.setData({
          upDataString: key0 + key2 + key4 + key6,
          downDataString: key1 + key3 + key5 + key7,
        })
      }else {
        console.log(this.properties.itemData.baZi.length)
      }
    },

    handleToDetail(e) {
      this.triggerEvent("recordDetailEvent", e.currentTarget.id)
    },

    handleToDelete(e) {
      this.triggerEvent("recordDeleteEvent", e.currentTarget.id)
    }
  }
})